-module(calculator).
-export([add/1,add/2,subtract/2,divide/2,multiply/2]).

%% Adds two numbers
add(Num1, Num2) ->
  Num1 + Num2.
%% Add up a list of numbers
add([Head | Rest]) ->
  Head + add(Rest);
add([]) ->
  0.

%% Subtract two numbers
subtract(Num1, Num2) ->
  Num1 - Num2.

multiply(Num1, Num2) ->
  Num1 * Num2.

divide(Num1, Num2) when Num2 > 0 ->
  Num1 / Num2;
divide(Num1, Num2)  ->
  {error, "Cannot divide by zero"}.
